package com.gmall.java;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class StreamTest2 {

    public static void main(String[] args) {
        List<ProductSKU> list = Arrays.asList(
                new ProductSKU("apple", 10, new BigDecimal("19.99")),
                new ProductSKU("banana", 20, new BigDecimal("19.99")),
                new ProductSKU("orange", 10, new BigDecimal("29.99")),
                new ProductSKU("watermelon", 10, new BigDecimal("29.99")),
                new ProductSKU("papaya", 20, new BigDecimal("9.99")),
                new ProductSKU("apple", 10, new BigDecimal("9.99")),
                new ProductSKU("banana", 10, new BigDecimal("19.99")),
                new ProductSKU("apple", 20, new BigDecimal("9.99"))
        );

//        Collections.sort(list,(o1,o2)->{return o1.getQty()-o2.getQty();});
//
//        list.forEach((ProductSKU o)->{
//            System.out.println(o);
//        });

        list.stream()
                //.filter((a)->{return a.getPrice().doubleValue()>10;})
                .map((a)->{return a.getName();})
                .filter((a)->{return a.startsWith("a");})
                .limit(2)
                .map((a)->{return a.startsWith("w")?1:0;})
                .collect(Collectors.toList());





    }

}
